/* eslint-disable InnerIPLeak */
import { axios } from '@/utils/request'
// 软件管控页面列表
function getSoftwareMCList (data) {
  return axios({
    url: '/sw-repository/basic/page',
    method: 'get',
    params: data
  })
}
// 查询申请人信息
function getApplicantInfo (data) {
  return axios({
    url: '/sw-repository/basic/info',
    method: 'get',
    params: data
  })
}
// 查询版本号列表
function getMcVersionList (data) {
  return axios({
    url: '/sw-repository/basic/version',
    method: 'get',
    params: data
  })
}
// 查询上传文件的烧写类型列表
function searchFlushType () {
  return axios({
    url: '/sw-repository/apply/file-reprogram-type',
    method: 'get'
  })
}
// 查询对应升级包类型下的烧写类型列表
function searchFlushTypeRelated (data) {
  return axios({
    url: '/sw-repository/apply/reprogram-type/' + data,
    method: 'get'
  })
}
// 软件管控表单存为草稿
function saveAsDraft (data) {
  return axios({
    url: '/sw-repository/apply/draft',
    method: 'post',
    data
  })
}
// 软件管控在线差分（获得目标版本列表数据）
function getOnlineDiffList (data) {
  return axios({
    url: '/sw-repository/basic/version/different/target/'+data,
    method: 'get'
  })
}
// 软件管控在线差分（原始版本列表数据）
function getOnlineDiffOrigin (data) {
  return axios({
    url: '/sw-repository/basic/version/different/original/page',
    method: 'get',
    params: data
  })
}
// 软件管控在线差分（获取差分的目标版本Id）
function getOnlineDiffTargetId (data) {
  return axios({
    url: '/sw-repository/basic/version/target/'+data,
    method: 'get',
  })
}
// 差分包组装文件
function createOnlineDiffFile (data) {
  return axios({
    url: '/sw-repository/apply/build/file',
    method: 'post',
    data
  })
}
// 新建表单提交
function submitNewForm (data) {
  return axios({
    url: '/sw-repository/apply',
    method: 'post',
    data
  })
}
// 编辑表单提交
function submitEditedForm (data) {
  return axios({
    url: '/sw-repository/apply',
    method: 'put',
    data
  })
}

// 查询表单详情
function queryFormDetail (data) {
  return axios({
    url: '/sw-repository/apply/detail/' + data,
    method: 'get'
  })
}

// 查询差分软件包下载
function checkDiffPackageDownload (data) {
  return axios({
    url: '/sw-repository/apply/check/' + data,
    method: 'get'
  })
}

// 查询复制表单详情
function getCopyDetail (data) {
  return axios({
    url: '/sw-repository/apply/copy-detail/' + data,
    method: 'get'
  })
}
// 查询复制表单详情
function getDiffCopyDetail (data) {
  return axios({
    url: '/sw-repository/apply/diff/copy/' + data,
    method: 'get'
  })
}

// 上架表单
function listingForm (data) {
  return axios({
    url: '/sw-repository/basic/up',
    method: 'put',
    params: data
  })
}
// 下架表单
function offshelfForm (data) {
  return axios({
    url: '/sw-repository/basic/down',
    method: 'put',
    params: data
  })
}
// 废止表单
function repealForm (data) {
  return axios({
    url: '/workflow-manage/instance/repeal',
    method: 'put',
    data: data
  })
}
// 删除表单
function deleteSoftMCForm (data) {
  return axios({
    url: '/sw-repository/basic/del',
    method: 'delete',
    data
  })
}
// 发起表单审核
function initiateAudit (data) {
  return axios({
    url: '/sw-repository/apply/start',
    method: 'post',
    data
  })
}
// Ecu下拉名称
function getECUSelectOption (params) {
  return axios({
    url: '/vehicle-service/ecu/select/model-code',
    method: 'get',
    params
  })
}
// 验证版本号是否重复
function validateVersionName (data) {
  return axios({
    url: '/sw-repository/basic/version/duplicate-check',
    method: 'get',
    params: data
  })
}
// 验证烧写类型是否重复
function validateReprogramType (data) {
  return axios({
    url: '/sw-repository/basic/version/vaildCreEdiTable',
    method: 'get',
    params: data
  })
}

// 导入变更信息
function importChangeFile (data) {
  return axios({
    url: '/sw-repository/apply/import/change',
    method: 'post',
    data
  })
}
// 下载变更信息导入模板
function downloadTemplateFile () {
  return axios({
    url: '/sw-repository/apply/template/excel',
    method: 'get',
    responseType: 'blob'
  })
}
function downloadUploadedFile (params) {
  return axios({
    url: '/sw-repository/apply/download',
    method: 'post',
    params,
    responseType: 'blob'
  })
}
// 查询所有版本号
function getVersionNum () {
  return axios({
    url: '/sw-repository/basic/version/findVersionNum',
    method: 'get'
  })
}
export default {
  getSoftwareMCList,
  getApplicantInfo,
  offshelfForm,
  listingForm,
  deleteSoftMCForm,
  repealForm,
  getECUSelectOption,
  submitNewForm,
  saveAsDraft,
  getOnlineDiffList,
  getOnlineDiffOrigin,
  getOnlineDiffTargetId,
  createOnlineDiffFile,
  getMcVersionList,
  searchFlushType,
  searchFlushTypeRelated,
  queryFormDetail,
  getCopyDetail,
  getDiffCopyDetail,
  initiateAudit,
  downloadUploadedFile,
  importChangeFile,
  downloadTemplateFile,
  validateVersionName,
  validateReprogramType,
  submitEditedForm,
  getVersionNum,
  checkDiffPackageDownload
}
